package com.nb82.core;

import java.util.LinkedHashMap;
import java.util.Map;

import android.app.Application;
import android.util.Log;
/**
 * 
 * @author cxd
 * 
 */
public abstract class AppContextControll extends Application implements
		Thread.UncaughtExceptionHandler {
	// public static KennerControll controll;
	public Map<Object, Object> cache ; 
	@Override
	public abstract void uncaughtException(Thread thread, Throwable ex);

	@Override
	public void onCreate() {
		Log.i("AppContextControll.onCreate() === > ", "����������......");
		super.onCreate();

		Thread.setDefaultUncaughtExceptionHandler(this);
		init();

	}

	private void init() {
		Log.i("AppContextControll.init() === > ",
				"init()......  start   to scanner  @Service��&&��@Bean����");
		try {
			// TODO ɨ��������@service��̬������ ���ڿ������٣� ֱ���½�

			// Set<Class<?>> set = BaseUtil.getClasses("com.nb82.core");
			// Iterator<Class<?>> it = set.iterator();
			// Map< String , Object> map = new HashMap<String, Object>();
			// while(it.hasNext()){
			// Class clazz = it.next();
			// Annotation ann = clazz.getAnnotation(Service.class);
			// if (ann != null ) {
			// map.put(clazz.getSimpleName(), clazz.newInstance()) ;
			// }
			// }
			// GlobalUtil.controlls.putAll(map);

//			Map<String, Object> map = new HashMap<String, Object>();
//			KennerControll kennerControll = KennerControll.getInstance();
//			// BeanFactoryControll beanFactoryControll =
//			// BeanFactoryControll.getInstance();
//			kennerControll.setListener(new SimpleTaskListener());
//			map.put("kennerControll", kennerControll);
//			// map.put("beanControll", beanFactoryControll);
//			GlobalUtil.controlls.putAll(map);
			cache = new LinkedHashMap<Object, Object>();
			KennerControll kennerControll = KennerControll.getInstance();
			kennerControll.setListener(new SimpleTaskListener());
			kennerControll.setCtx(getApplicationContext());
			cache.put("kennerControll", kennerControll);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Override
	public void onLowMemory() {
		Log.w("AppContextControll.onLowMemory() === > ", "onLowMemory:");
		super.onLowMemory();
	}
}
